package com.gipson.amc.utils.security;

import com.gipson.amc.entity.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

public class ShiroUtils {

    public static User getCurrentUser(){
        return (User) SecurityUtils.getSubject().getPrincipal();
    }

    public static boolean hasPermission(String permission){
        Subject subject = SecurityUtils.getSubject();
        return subject != null && subject.isPermitted(permission);
    }

    public static boolean hasRole(String role){
        Subject subject = SecurityUtils.getSubject();
        return subject != null && subject.hasRole(role);
    }

}
